package com.meihua.shellapp.utils;

import android.content.Context;
import android.view.WindowManager;

/**
 * 全局常亮类
 */

public class ConstantUtils {

    private static ConstantUtils utils;

    public int screenH;//屏幕高度
    public int screenW;//屏幕宽度

    private ConstantUtils() {
    }

    public static ConstantUtils getInstance() {
        if (utils == null) {
            utils = new ConstantUtils();
        }
        return utils;
    }

    /**
     * 获取屏幕宽度
     *
     * @param context
     * @return
     */
    public int getScreenW(Context context) {
        if (screenW == 0) {
            WindowManager wm = (WindowManager) context
                    .getSystemService(Context.WINDOW_SERVICE);
            screenW = wm.getDefaultDisplay().getWidth();
            screenH = wm.getDefaultDisplay().getHeight();
        }

        return screenW;
    }

    /**
     * 获取屏幕高度
     *
     * @param context
     * @return
     */
    public int getScreenH(Context context) {
        if (screenH == 0) {
            WindowManager wm = (WindowManager) context
                    .getSystemService(Context.WINDOW_SERVICE);
            screenW = wm.getDefaultDisplay().getWidth();
            screenH = wm.getDefaultDisplay().getHeight();
        }

        return screenH;
    }

}
